/**
 * Description：成品检验 hooks
 * Copyright (c) : 通力凯顿（北京）系统集成有限公司
 * Writer：朱楠
 * date: 2024.8.1
 */
const { reactive, ref, unref } = Vue
import { useFetch } from '../../../Scripts/hooks/useFetch.js'
const { ElMessage, ElMessageBox, ElCheckbox, ElInput, ElSelect, ElOption } = ElementPlus
import { useCommon } from '../useCommon.js';
import { useUserRoles } from '../../../Scripts/hooks/useUserRoles.js';

export function useFinishCheck() {
  const finishCheckDialogVisible = ref(false);//成品检验默认隐藏
  const finishCheckSelectedContainerList = ref([]);//批次表格数据
  // 外观检查列表
  const appearanceCheckList = ref([
    { CheckName: '表面清洗', CheckResult: '合格' },
    { CheckName: '去尖角毛刺', CheckResult: '合格' },
    { CheckName: '零件标印', CheckResult: '合格' },
  ]);

  const checkContentList = ref([]);//检验内容表格数据
  const checkContentListRef = ref(null);//检验内容表格ref

  const finishCheckLossInfoList = ref([]);//报废信息表格数据

  // 报废信息表格列配置
  const finishCheckLossInfoListColumnConfig = reactive({
    childcontainer: false,//流水卡序号
    childContainerShow: false,//批次号
  });

  const { lossReasonList, getLossReasonByGroupName } = useCommon();
  const { userList: finishCheckDialogCheckerList, getFactoryUsersByRoleName } = useUserRoles();

  const finishCheckDialogForm = reactive({
    mfgOrderName: '',//生产订单
    planQty: '',//计划数
    containertypename: '',//流水卡类型
    workflowstepname: '',//当前工序
    productInfo: '',//零件图号及版本
    productDesc: '',//零件描述
    batchNO: '',//炉批号
    submitQty: '',//提交数
    acceptanceQty: '',//检验总数【合格数】
    sumLossQty: 0,//报废数
    sumDefeatQty: 0,//超差数
    sumReworkQty: 0,//返修数
    defectBillNo: '', //超差审理单
    checkResult: '',//送检结论
    otherQualityResult: '',//其他质量文件
    measureCheck: '合格', //量具检测
    techniqueCondition: '',//技术条件
    checkNote: '',//附注
    checkers: [],//检验员
    addRowCount: 0,//序号数
    selectType: '/',//类型
  });

  // 初始化成品检验对话框数据
  /**
   * 
   * @param {*} currentSelectContainer:批次当前信息 
   * @param {*} selectionRows:检验主页面勾选的批次表格数据
   * @param {*} userInfo 
   * @param {*} factoryUserattributeList 
   */
  async function initFinishCheckDialogData(currentSelectContainer, selectionRows, userInfo, factoryUserattributeList) {
    finishCheckDialogVisible.value = true;// 打开对话框
    const {
      mfgordername, planqty, containertypename,
      containertype, productdescription, productname, productrevision, workflowstepname
    } = currentSelectContainer;

    // 将主界面所选【批次信息】和【批次明细】表格信息合并成一个宽表
    let mergeData = [];
    for (const i of selectionRows) {
      mergeData.push({ ...currentSelectContainer, ...i });
    }

    // 1.获取报废原因列表数据
    await getLossReasonByGroupName({ url: '../../../Ashx/FetchCommonHandler.ashx', method: 'getLossReasonByGroupName', lossreasongroupname: '报废原因组' });

    // 2.获取报工人数据
    const workerData = await getWorkerInfo(mergeData, userInfo, factoryUserattributeList);

    // 3.查询分厂检验员
    await getFactoryUsersByRoleName({ url: `../../../Ashx/FetchCommonHandler.ashx`, method: 'getFactoryUsersByRoleName', factoryid: userInfo.value.factoryid, rolename: '检验员' });

    // 4.查询同件号、同工序成检的继承信息（如果有给页面相关文本框及表格赋值）
    await bindCheckInheritInfo(mergeData);

    // 给【流水卡信息】表格赋值
    finishCheckSelectedContainerList.value = mergeData;

    for (const i of finishCheckSelectedContainerList.value) {
      if (i.containertype === 7) {
        i.wipqty = 1;
      }
    }

    // 给下方表格数据赋值
    for (const i of workerData) {
      i.LossQty = 0;// 模板列中【报废数】默认为0
      i.Defectqty = 0;// 模板列中【超差数】默认为0
      i.ReworkQty = 0;// 模板列中【返修数】默认为0
      i.reasonid = '';// 模板列中【报废原因】默认为空
      i.checked = true;//默认全选
    }

    // 给【报废信息】表格赋值
    finishCheckLossInfoList.value = workerData;

    // 给报废表格流水卡号列赋值
    for (const i of workerData) {
      i.realcontainername = mergeData.filter(m => m.containerid === i.containerid)[0].containername;
    }

    for (const m of finishCheckSelectedContainerList.value) {
      if (containertype === 7) {
        m.checkqty = 1;//单件单卡【待检数】都为1
      }
      if (containertype === 3) {
        m.checkqty = workerData.length;//子序号批，【待检数】为表格行数
      }
      if (containertype === 2) {
        //数量批，【待检数】= 在制数 - 报废数
        m.checkqty = m.wipqty - workerData.reduce((accumulator, currentItem) => accumulator + currentItem.lossqty, 0);
      }
    }

    // 给【合格数】文本框赋初始值
    if (containertype === 7) {
      finishCheckDialogForm.acceptanceQty = 1;
    } else {
      // 非单检单卡，合格数默认取【待检数】的值
      finishCheckDialogForm.acceptanceQty = finishCheckSelectedContainerList.value[0].checkqty;
    }

    // 计算【合格数】、【报废数】、【超差数】、【返修数】总数并赋值

    finishCheckDialogForm.mfgOrderName = mfgordername;
    finishCheckDialogForm.workflowstepname = workflowstepname;
    finishCheckDialogForm.planQty = planqty;
    finishCheckDialogForm.containertypename = containertypename;
    finishCheckDialogForm.containertype = containertype;
    finishCheckDialogForm.productDesc = productdescription;
    finishCheckDialogForm.productInfo = `${productname}:${productrevision}`;
    finishCheckDialogForm.submitQty = finishCheckSelectedContainerList.value[0].checkqty;//【提交数】文本框
    finishCheckDialogForm.batchNO = finishCheckSelectedContainerList.value[0].containername;//【炉批号】文本框

    // 【检验员】默认选择当前用户
    if (finishCheckDialogCheckerList.value.length > 0
      && finishCheckDialogCheckerList.value.some(i => i.employeeid === userInfo.value.employeeid)) {
      finishCheckDialogForm.checkers = [userInfo.value.employeeid];
    }

    if (containertype != 2) {
      finishCheckLossInfoListColumnConfig.childcontainer = false;//隐藏【流水卡序号】列
      finishCheckLossInfoListColumnConfig.childContainerShow = true;//显示【批次号】列
      for (const i of workerData) {
        if (containertype === 7) {
          const filterData = mergeData.filter(item => item.containerid === i.containerid);
          if (filterData.length > 0) {
            i.childContainerShow = filterData[0].containername.split('/')[1];//从批次号中截取【批次号】的值
            i.childContainerName = filterData[0].containername;
          }
        }
        if (containertype === 3) {
          i.childContainerShow = i.containername.split('/')[1];//从批次号中截取【批次号】的值
          i.childContainerName = i.containername;
        }
        // 按批次号排序
        workerData.sort((a, b) => a.childContainerShow - b.childContainerShow);
      }
    } else {
      finishCheckLossInfoListColumnConfig.childcontainer = false;//隐藏【流水卡序号】列
      finishCheckLossInfoListColumnConfig.childContainerShow = false;//隐藏【批次号】列
    }

    // 重新根据状态渲染【批次号】显示/隐藏
    finishCheckTableColumns.value.filter(i => i.key === 'childContainerShow')[0].hidden = !finishCheckLossInfoListColumnConfig.childContainerShow;
  }

  // 获取报工信息
  async function getWorkerInfo(mergeData, userInfo, factoryUserattributeList) {
    let checkerid = "", workerSelectChecker = '否';
    if (factoryUserattributeList.value.some(i => i.userattributename === '报工选择检验' && i.attributevalue === '是')) {
      checkerid = userInfo.value.employeeid;
      workerSelectChecker = '是';
    }
    const { data } = await useFetch({
      url: `../../../Ashx/ContainerCheckVue3PageHandler.ashx?actions=getWorkerInfo`,
      data: {
        type: 'getWorkerInfo',
        postData: mergeData,
        checkerid,
        workerSelectChecker//报工选择检验
      }
    });
    return data.value;
  }

  // 报废信息表格单元格blur事件
  function finishCheckDialogCellBlur(label, row, containerList) {
    const mapping = [
      { cellname: '超差数', fieldname: 'Defectqty' },
      { cellname: '报废数', fieldname: 'LossQty' },
      { cellname: '返修数', fieldname: 'ReworkQty' },
      { cellname: '报废原因', fieldname: 'reasonid' },
    ];
    const { fieldname } = mapping.filter(i => i.cellname === label)[0];
    const LossQty = parseInt(row.LossQty);//输入的报废数
    const Defectqty = parseInt(row.Defectqty);//输入的超差数
    const ReworkQty = parseInt(row.ReworkQty);//输入的返修数

    const reg = /^[1-9]\d*$/;//正整数正则
    const { containertype } = containerList[0];
    let qty = containertype === 2 ? parseInt(row.qty) : 1;//报工数，单件单卡和子序号批报工数都为1

    if (label === '报废原因') {
      if (!row.reasonid) {
        row.LossQty = 0;
        setCheckInfoSumData();
        return;
      }
      if (LossQty === 0) {
        row.reasonid = "";
        return ElMessage({ type: 'error', message: `请先填写报废数`, grouping: true });
      }
      setCheckInfoSumData();
      return;
    }

    // 先判断文本框是否为有效数字
    if (!reg.test(row[fieldname])) {
      row[fieldname] = 0;
      if (label === '报废数') {
        row.reasonid = "";//清空【报废原因】
      }
      setCheckInfoSumData();
      return;
    }

    // 校验报废数 + 返修数 + 超差数是否大于报工数
    if (LossQty + Defectqty + ReworkQty > qty) {
      row[fieldname] = 0;
      if (label === '报废数') {
        row.reasonid = "";//清空【报废原因】
      }
      setCheckInfoSumData();
      return ElMessage({ type: 'error', message: `报废数 + 返修数 + 超差数不能大于${qty}`, grouping: true });
    }
    setCheckInfoSumData();
  }

  // 给【报废数】【超差数】【返修数】文本框赋值
  function setCheckInfoSumData() {
    let sumLossQty = 0, sumDefeatQty = 0, sumReworkQty = 0;
    for (const i of finishCheckLossInfoList.value) {
      const LossQty = parseInt(i.LossQty);
      const Defectqty = parseInt(i.Defectqty);
      const ReworkQty = parseInt(i.ReworkQty);

      sumLossQty += LossQty;
      sumDefeatQty += Defectqty;
      sumReworkQty += ReworkQty;
    }
    finishCheckDialogForm.sumLossQty = sumLossQty;
    finishCheckDialogForm.sumDefeatQty = sumDefeatQty;
    finishCheckDialogForm.sumReworkQty = sumReworkQty;

    if (finishCheckDialogForm.containertypename !== '单件单卡') {
      finishCheckDialogForm.acceptanceQty = finishCheckDialogForm.submitQty - sumLossQty;
    }
  }

  // 检验前数据校验
  function validateCheckData() {
    const selection = finishCheckLossInfoList.value.filter(row => row.checked);
    if (selection.length === 0) {
      ElMessage({ type: 'error', message: `请选择数据`, grouping: true });
      return false;
    }
    if (selection.some(i => parseInt(i.LossQty) > 0 && !i.reasonid)) {
      ElMessage({ type: 'error', message: `报废数不为0，请选择【报废原因】`, grouping: true });
      return false;
    }
    // 检验待添加验证
    if (!finishCheckDialogForm.measureCheck) {
      ElMessage({ type: 'error', message: `【量具检查】不能为空`, grouping: true });
      return false;
    }
    return true;
  }

  // 添加检验内容行
  function finishCheckDialogAddCheckRows() {
    if (finishCheckDialogForm.checkers.length === 0) {
      return ElMessage({ type: 'error', message: `检验员不能为空`, grouping: true });
    }
    const reg = /^(1\d|[1-9]|20)$/
    if (!reg.test(finishCheckDialogForm.addRowCount)) {
      finishCheckDialogForm.addRowCount = 0;
      return ElMessage({ type: 'error', message: `添加项数只能为1~20整数`, grouping: true });
    }
    const count = parseInt(finishCheckDialogForm.addRowCount);//添加的项数
    const checkerList = finishCheckDialogCheckerList.value;//检验员列表
    for (let index = 0; index < count; index++) {
      let employeeids = "", fullnames = "";
      for (const i of finishCheckDialogForm.checkers) {
        employeeids += `${i},`;
        fullnames += `${checkerList.filter(m => m.employeeid === i)[0].fullname},`;
      }
      employeeids = employeeids.slice(0, -1);//移除末尾逗号
      fullnames = fullnames.slice(0, -1);//移除末尾逗号
      checkContentList.value.push({ checkcontent: '合格', checkerEmployeeids: employeeids, checkerFullnames: fullnames });
    }
    // 检验内容全选
    checkContentListRef.value.toggleAllSelection();
  }

  // 检验内容确认
  function finishCheckDialogCheckRowsConfirm() {
    const selection = checkContentListRef.value.getSelectionRows();
    if (selection.length === 0) {
      return ElMessage({ type: 'error', message: `请先选择要确认的检测内容`, grouping: true });
    }

    ElMessageBox.confirm(`你确认要将所选的检测内容更新为 ${finishCheckDialogForm.selectType} 吗?`, '确认', { type: 'warning' }).then(async () => {
      for (const m of selection) { m.checkcontent = finishCheckDialogForm.selectType; }
    }).catch(() => {
      ElMessage({ type: 'info', message: '已取消' });
    });
  }

  // 清空检验内容
  function finishCheckDialogCheckRowsClear() {
    ElMessageBox.confirm(`你确认要清空数据吗?`, '确认', { type: 'warning' }).then(async () => {
      checkContentList.value = [];
      finishCheckDialogForm.addRowCount = 0;
    }).catch(() => {
      ElMessage({ type: 'info', message: '已取消' });
    });
  }

  // 确认检验员
  function finishCheckDialogCheckerConfirm() {
    if (finishCheckDialogForm.checkers.length === 0) {
      return ElMessage({ type: 'error', message: `检验员不能为空`, grouping: true });
    }
    if (checkContentList.value.length === 0) {
      return ElMessage({ type: 'error', message: `请先添加检测内容`, grouping: true });
    }
    const selection = checkContentListRef.value.getSelectionRows();
    if (selection.length === 0) {
      return ElMessage({ type: 'error', message: `请先选择要添加的检测内容`, grouping: true });
    }

    // 更新检验员
    for (const item of selection) {
      let employeeids = "", fullnames = "";
      for (const i of finishCheckDialogForm.checkers) {
        employeeids += `${i},`;
        // 从【检验员】列表中匹配出检验员姓名
        fullnames += `${finishCheckDialogCheckerList.value.filter(m => m.employeeid === i)[0].fullname},`;
      }
      employeeids = employeeids.slice(0, -1);//移除末尾逗号
      fullnames = fullnames.slice(0, -1);//移除末尾逗号

      item.checkerEmployeeids = employeeids;//检验员id
      item.checkerFullnames = fullnames;//检验员姓名
    }
  }

  // 查询同件号、同工序成检的继承信息, 并给页面相关文本框及表格赋值
  async function bindCheckInheritInfo(mergeData) {
    const { data: inheritData } = await useFetch({
      url: `../../../Ashx/ContainerFinishCheckVue3PageHandler.ashx?actions=getLastFinishCheckInheritInfo`,
      data: {
        type: 'getLastFinishCheckInheritInfo',
        productname: mergeData[0].productname,
        workflowstepname: mergeData[0].workflowstepname,
      }
    });
    if (inheritData.value.length > 0) {
      finishCheckDialogForm.techniqueCondition = inheritData.value[0].techniquecondition;//更新【技术条件】文本框的值
      finishCheckDialogForm.checkNote = inheritData.value[0].checknote;//更新【/附注】文本框的值

      appearanceCheckList.value = [];//先清空外观检查列表
      checkContentList.value = [];//清空尺寸检查

      for (const item of inheritData.value) {
        const arrAppearance = ['表面清洗', '去尖角毛刺', '零件标印'];
        if (arrAppearance.some(m => m === item.checkdetailname)) {
          appearanceCheckList.value.push({ CheckName: item.checkdetailname, CheckResult: item.checkdetailvalue });
          continue;
        }
        if (item.checkdetailname === '量具检查') {
          finishCheckDialogForm.measureCheck = item.checkdetailvalue;//更新【量具检查】文本框的值
          continue;
        }
      }

      const checkdetailnames = inheritData.value.filter(i => i.checkdetailname.indexOf('零件尺寸') !== -1);//过滤出零件尺寸
      const uniquenames = [];
      // 获取检测内容（已去重）
      checkdetailnames.forEach(m => {
        if (uniquenames.indexOf(m.checkdetailname) == -1) {
          uniquenames.push(m.checkdetailname);
        }
      });

      for (const item of uniquenames) {
        let employeeids = "", fullnames = "", checkcontent = "";
        for (const i of checkdetailnames.filter(i => i.checkdetailname === item)) {
          employeeids += `${i.employeeid},`;
          fullnames += `${i.employeename},`;
          checkcontent = i.checkdetailvalue;
        }
        employeeids = employeeids.slice(0, -1);//移除末尾逗号
        fullnames = fullnames.slice(0, -1);//移除末尾逗号
        checkContentList.value.push({ checkcontent: checkcontent, checkerEmployeeids: employeeids, checkerFullnames: fullnames });
      }
      finishCheckDialogForm.addRowCount = uniquenames.length;//更新【序号数】文本框的值
      if (checkContentList.value.length > 0) {
        // 检验内容全选
        checkContentListRef.value.toggleAllSelection();
      }
    }
  }

  // 保存【成品检验】数据
  async function saveFinishCheck(userInfo) {
    if (!validateCheckData()) { return; }
    const selection = finishCheckLossInfoList.value.filter(row => row.checked);// 报废信息表格数据

    const CheckerData = [];//检测内容 = 量具检查+外观检查+尺寸检查
    // 1.外观检查
    for (const item of appearanceCheckList.value) {
      CheckerData.push({ CheckName: item.CheckName, CheckValue: item.CheckResult, CheckEmployeeID: userInfo.value.employeeid });
    }

    // 2.追加检验内容
    const checkContentList = checkContentListRef.value.getSelectionRows().filter(i => i.checkcontent !== '/');//排除检验内容为 / 的
    checkContentList.forEach((item, index) => {
      const employeeids = item.checkerEmployeeids;// 检测内容所选检验员（可能会有多条，逗号分隔）
      if (employeeids.indexOf(',') > -1) {
        const arrEmp = employeeids.split(',');
        // 检验员多选时，拆分成多条分别插入
        for (const emp of arrEmp) {
          CheckerData.push({ CheckName: `零件尺寸${index + 1}`, CheckValue: item.checkcontent, CheckEmployeeID: emp });
        }
      } else {
        CheckerData.push({ CheckName: `零件尺寸${index + 1}`, CheckValue: item.checkcontent, CheckEmployeeID: employeeids });
      }
    });

    // 3.追加量具检查
    CheckerData.push({ CheckName: `量具检查`, CheckValue: finishCheckDialogForm.measureCheck, CheckEmployeeID: userInfo.value.employeeid });

    const { data, status: { msg } } = await useFetch({
      url: `../../../Ashx/ContainerFinishCheckVue3PageHandler.ashx?actions=SaveFinishCheckInfo`,
      data: {
        type: 'SaveFinishCheckInfo',
        containerList: finishCheckSelectedContainerList.value,//勾选的批次信息
        lossInfoList: selection,//所选择的报废表格数据
        CheckerData: CheckerData,//检测内容
        employeename: userInfo.value.employeename,//检验人
        ...finishCheckDialogForm
      }
    });
    return { data, msg };
  }

  // 选择框单元格组件
  const SelectionCell = (props) => {
    return Vue.h(ElCheckbox, {
      modelValue: props.value,
      indeterminate: props.intermediate || false,
      onChange: props.onChange
    })
  };

  // 定义列配置
  const finishCheckTableColumns = ref([
    {
      key: 'selection',
      width: 50,
      // 行选择框渲染
      cellRenderer: ({ rowData }) => {
        const handleChange = (checked) => { rowData.checked = checked }
        return Vue.h(SelectionCell, { value: rowData.checked, onChange: handleChange })
      },
      // 表头全选框渲染
      headerCellRenderer: () => {
        let _data = unref(finishCheckLossInfoList)
        const handleCheckAll = (checked) => { finishCheckLossInfoList.value = _data.map(row => ({ ...row, checked })) }
        const allChecked = _data.every(row => row.checked);
        const someChecked = _data.some(row => row.checked);
        const isIntermediate = someChecked && !allChecked;
        return Vue.h(SelectionCell,
          { value: allChecked, intermediate: isIntermediate, onChange: handleCheckAll }
        )
      }
    },
    // 行号
    { key: 'rowNumber', title: '序号', width: 60, cellRenderer: ({ rowIndex }) => { return Vue.h('div', null, rowIndex + 1); } },
    { key: 'containerid', dataKey: 'containerid', title: '批次id', width: 80, align: 'left', hidden: true },
    { key: 'workerid', dataKey: 'workerid', title: 'workerid', width: 80, align: 'left', hidden: true },
    { key: 'realcontainername', dataKey: 'realcontainername', title: '流水卡号', width: 300, align: 'left' },
    { key: 'fullname', dataKey: 'fullname', title: '报工人', width: 70, align: 'left' },
    { key: 'createdate', dataKey: 'createdate', title: '报工时间', width: 100, align: 'left', cellRenderer: ({ rowData }) => { return rowData.createdate.split('T')[0] } },
    { key: 'qty', dataKey: 'qty', title: '报工数', width: 70, align: 'left' },
    { key: 'childcontainer', dataKey: 'childcontainer', title: '流水卡序号', width: 100, align: 'left', hidden: !finishCheckLossInfoListColumnConfig.childcontainer },
    {
      key: 'childContainerShow', dataKey: 'childContainerShow', title: '批次号', width: 100, align: 'left',
      hidden: !finishCheckLossInfoListColumnConfig.childContainerShow
    },
    {
      key: 'Defectqty', dataKey: 'Defectqty', title: '超差数', width: 100, align: 'left',
      cellRenderer: ({ rowData }) => {
        return Vue.h(ElInput, {
          modelValue: rowData.Defectqty,
          'onUpdate:modelValue': (value) => {
            rowData.Defectqty = value.trim();
          },
          onBlur: () => {
            finishCheckDialogCellBlur('超差数', rowData, finishCheckSelectedContainerList.value)
          }
        });
      }
    },
    {
      key: 'LossQty', dataKey: 'LossQty', title: '报废数', width: 100, align: 'left',
      cellRenderer: ({ rowData }) => {
        return Vue.h(ElInput, {
          modelValue: rowData.LossQty,
          'onUpdate:modelValue': (value) => {
            rowData.LossQty = value.trim();
          },
          class: 'custom-input-red',
          placeholder: '请输入',
          prefixIcon: 'circle-close-filled',
          onBlur: () => {
            finishCheckDialogCellBlur('报废数', rowData, finishCheckSelectedContainerList.value)
          }
        });
      }
    },
    {
      key: 'reasonid', dataKey: 'reasonid', title: '报废原因', width: 160, align: 'left',
      cellRenderer: ({ rowData }) => {
        // 处理下拉框选择事件
        const handleChange = (value) => {
          rowData.reasonid = value; // 更新当前行数据
        };

        // 构建下拉框选项（ElOption）
        const options = lossReasonList.value.map(option =>
          Vue.h(ElOption, { label: option.lossreasonname, value: option.lossreasonid })
        );

        // 构建下拉框（ElSelect）并嵌套选项
        return Vue.h(ElSelect, {
          modelValue: rowData.reasonid,
          'onUpdate:modelValue': handleChange,
          placeholder: '请选择状态',
          clearable: true,
          onBlur: () => {
            finishCheckDialogCellBlur('报废原因', rowData, finishCheckSelectedContainerList.value)
          }
        },
          options // 子节点：下拉选项列表
        );
      },
    },
    {
      key: 'ReworkQty', dataKey: 'ReworkQty', title: '返修数', width: 100, align: 'left',
      cellRenderer: ({ rowData }) => {
        return Vue.h(ElInput, {
          modelValue: rowData.ReworkQty,
          'onUpdate:modelValue': (value) => {
            rowData.ReworkQty = value.trim();
          },
          class: 'custom-input-red',
          placeholder: '请输入',
          prefixIcon: 'circle-close-filled',
          onBlur: () => {
            finishCheckDialogCellBlur('返修数', rowData, finishCheckSelectedContainerList.value)
          }
        });
      }
    },
    { key: 'qty', dataKey: 'qty', title: '原始报工数', width: 60, align: 'left', hidden: true },
    { key: 'containerstepworkreportid', dataKey: 'containerstepworkreportid', title: '报工ID', width: 60, align: 'left', hidden: true },
    { key: 'checktype', dataKey: 'checktype', title: '报工类型', width: 60, align: 'left', hidden: true }
  ]);

  return {
    finishCheckDialogVisible,
    finishCheckSelectedContainerList,
    appearanceCheckList,//【外观检查】表格数据
    checkContentList,//【检验内容】表格数据
    checkContentListRef,//检验内容表格ref引用
    finishCheckDialogCheckerList,//分厂检验员列表
    finishCheckLossInfoList,//报废品表格
    finishCheckDialogForm,
    finishCheckDialogAddCheckRows,//添加检验内容行
    finishCheckDialogCheckRowsConfirm,//检验内容确认
    finishCheckDialogCheckRowsClear,//清空检测内容
    finishCheckDialogCheckerConfirm,//确认检验员
    initFinishCheckDialogData,
    saveFinishCheck,//保存成品检验
    finishCheckTableColumns//报废品表格列
  };
}